package com.hylanda.pb.service;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import com.hylanda.pb.dao.PBLocalDao;
import com.hylanda.pb.entity.PBLocal;
import com.hylanda.pb.model.PBLocalQo;


@Service
public class PBLocalService {
    @Autowired
    private PBLocalDao pBLocalDao;

    public PBLocal findById(Long id) {
    	PBLocal pBLocal = pBLocalDao.findEntity(PBLocal.class, id);
        return pBLocal;
    }

    public PBLocal create(PBLocal pBLocal) {
        PBLocal newPBLocal = pBLocalDao.save(pBLocal);
        return newPBLocal;
    }

    public int update(PBLocal pBLocal) {
        return pBLocalDao.update(pBLocal);
    }

    public void delete(Long id) {
    	pBLocalDao.delete(PBLocal.class, id);
    }

    public Page<PBLocal> findPage(PBLocalQo pBLocalQo){
       Map<String, Object> fieldsFilter=new HashMap<String, Object>();
       if(StringUtils.isNotEmpty(pBLocalQo.getName())){
    	   fieldsFilter.put("name", pBLocalQo.getName());
       }
       return pBLocalDao.findPage(pBLocalQo);
    }
   

}
